package demo

import (
	"fmt"

	"github.com/gin-gonic/gin"
)

func MiddlewareQ() {
	Router := gin.Default()
	api := Router.Group("api")
	api.Use(CM1, CM2)
	api.GET("/", Home2)
	Router.Run(":8080")
}

func Home2(c *gin.Context) {
	fmt.Println("Home")
	c.String(200, "Home")
}

func CM1(c *gin.Context) {
	fmt.Println("M1 请求")
	c.Next() //放行
	// c.Abort() //拦截
	fmt.Println("M1 响应")
}

func CM2(c *gin.Context) {
	fmt.Println("M2 请求")
	c.Next()
	fmt.Println("M2 响应")
}
